//
//  ImpressionViewController.m
//  MPFindPart
//
//  Created by xalo on 16/5/6.
//  Copyright © 2016年 马鹏. All rights reserved.
//

#import "ImpressionViewController.h"
#import "ImpressionCell.h"
#import "FindViewController.h"
#import "PhotosViewController.h"
#import "FilmViewController.h"
#import "AmazingViewController.h"
@interface ImpressionViewController ()<UITableViewDataSource,UITableViewDelegate>
@property (weak, nonatomic) IBOutlet UITableView *tableView;
@property (nonatomic,retain)NSMutableArray *dataArray;//存放数据的数组

@end

@implementation ImpressionViewController

//造假数据
- (void)createData{
    
    NSDictionary *dic_1 = [NSDictionary dictionaryWithObjectsAndKeys:@"情侣笑话逗逗乐",@"text",[UIImage imageNamed:@"topic.png"],@"image", nil];
    NSDictionary *dic_2 = [NSDictionary dictionaryWithObjectsAndKeys:@"最美的时光(相册)",@"text",[UIImage imageNamed:@"photo.png"],@"image", nil];
    NSDictionary *dic_3 = [NSDictionary dictionaryWithObjectsAndKeys:@"影视资源",@"text",[UIImage imageNamed:@"TV.png"],@"image", nil];
    NSDictionary *dic_4 = [NSDictionary dictionaryWithObjectsAndKeys:@"惊喜的瞬间",@"text",[UIImage imageNamed:@"camera.png"],@"image", nil];
    self.dataArray = [@[dic_1,dic_2,dic_3,dic_4]mutableCopy];
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"印记";
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self createData];
    [self.tableView registerNib:[UINib nibWithNibName:@"ImpressionCell" bundle:nil] forCellReuseIdentifier:@"ImpressionCell"];
    
}

#pragma mark ---------tableView的代理方法
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.dataArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    ImpressionCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ImpressionCell" forIndexPath:indexPath];
    NSString *text = [self.dataArray[indexPath.row] objectForKey:@"text"];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.impressionLabel.text = text;
    cell.impressionImg.image = [self.dataArray[indexPath.row] objectForKey:@"image"];
    return cell;
}

#pragma mark ---------tableView的delegate相关的代理方法
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    return 100;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.row == 0) {
        
        self.hidesBottomBarWhenPushed = YES;
        UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        FindViewController *findVC = [storyBoard instantiateViewControllerWithIdentifier:@"FindViewController"];
        [self.navigationController pushViewController:findVC animated:YES];
        self.hidesBottomBarWhenPushed = NO;
    }else if (indexPath.row == 1){
        
        self.hidesBottomBarWhenPushed = YES;
        UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        PhotosViewController   *photoVC = [storyBoard instantiateViewControllerWithIdentifier:@"PhotosViewController"];
        [self.navigationController pushViewController:photoVC animated:YES];
        self.hidesBottomBarWhenPushed = NO;
        
    }else if (indexPath.row == 2){
        
        self.hidesBottomBarWhenPushed = YES;
        UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        FilmViewController *filmVC = [storyBoard instantiateViewControllerWithIdentifier:@"FilmViewController"];
        [self.navigationController pushViewController:filmVC animated:YES];
         self.hidesBottomBarWhenPushed = NO;
    }else if (indexPath.row == 3){
        
        self.hidesBottomBarWhenPushed = YES;
        UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        AmazingViewController *amazeingVC = [storyBoard instantiateViewControllerWithIdentifier:@"AmazingViewController"];
        [self.navigationController pushViewController:amazeingVC animated:YES];
        self.hidesBottomBarWhenPushed = NO;
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}
- (NSMutableArray *)dataArray{
    
    if (!_dataArray) {
        
        _dataArray = [NSMutableArray array];
    }
    return _dataArray;
}

@end
